<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>
<link rel="stylesheet" type="text/css" href="/static/component/laytp/module/cityPicker/city-picker.css">
<body id="optPage">
<form class="layui-form layui-form-pane" id="commentForm">
    <div class="page-title"><div class="page-title-con"><span id="flowsetname"></span><div class="move_title"></div><?php include "../public/subturn.php";?></div></div>
    <div class="main-container">

        <div class="block-generic">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">申请人</label>
                        <div class="layui-input-block">
                            <input type="text" id="flowuser" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">申请部门</label>
                        <div class="layui-input-block">
                            <input type="text" id="flowdept" readonly placeholder="请输入" autocomplete="off" class="layui-input readonly">
                        </div>
                    </div>
                </div>
            </div>


            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>基本信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>选择变更往来单位</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="dealid" class="layui-input dealid" onclick="openPage('../public/choose_dealcom.php?dom=dealid&page=dealcom_geng','80%','80%')">
                            <div class="choose_div" id="dealid" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_dealcom.php?dom=dealid&page=dealcom_geng','80%','80%')"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <div class="colorhong" style="line-height: 53px;margin-left: 20px">提示：以下信息为变更后信息，本变更申请通过后，将覆盖原有信息！</div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>单位名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" id="name" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>所属分类</label>
                        <div class="layui-input-block">
                            <div id="type"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>单位性质</label>
                        <div class="layui-input-block">
                            <div id="nature"></div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">法人代表</label>
                        <div class="layui-input-block">
                            <input type="text" name="legaler" id="legaler" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">注册地址</label>
                        <div class="layui-input-block">
                            <input type="text" name="zhuaddr" id="zhuaddr" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>


            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">税务类型</label>
                        <div class="layui-input-block">
                            <div id="taxtype"></div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">税号</label>
                        <div class="layui-input-block">
                            <input type="text" name="ratenum" id="ratenum" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">开票类型</label>
                        <div class="layui-input-block">
                            <div id="piaotype"></div>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">税点(%)</label>
                        <div class="layui-input-block">
                            <input type="number" name="rate" id="rate" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">单位地址</label>
                        <div class="layui-input-block">
                            <input type="text" name="unitaddr" id="unitaddr" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">电话号码</label>
                        <div class="layui-input-block">
                            <input type="text" name="phone" id="phone" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">开户银行</label>
                        <div class="layui-input-block">
                            <input type="text" name="bankname" id="bankname" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">银行账号</label>
                        <div class="layui-input-block">
                            <input type="text" name="banknum" id="banknum" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">经营类别</label>
                        <div class="layui-input-block">
                            <textarea id="genre" name="genre" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">单位评级</label>
                        <div class="layui-input-block">
                            <div id="danlevel"></div>
                        </div>
                    </div>
                </div>
            </div>



            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">联系人</label>
                        <div class="layui-input-block">
                            <input type="text" name="lianer" id="lianer" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">联系人手机号</label>
                        <div class="layui-input-block">
                            <input type="text" name="liantel" id="liantel" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">备注</label>
                        <div class="layui-input-block">
                            <textarea id="explain" name="explain" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">关联单据</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="flowrelas" class="layui-input flowrelas" onclick="openPage('../public/choose_flowrelas.php?dom=flowrelas','80%','80%');">
                            <div class="choose_div" id="flowrelas" key="1"></div>
                            <span class="choose_one" onclick="openPage('../public/choose_flowrelas.php?dom=flowrelas','80%','80%');"><i class="layui-icon layui-icon-search"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-hide" id="advanersDiv">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">预审人</label>
                        <div class="layui-input-block relative">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=advaners&type=user&single=2','770px','490px');"></div>
                                <div class="tanxiannei" id="advaners"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=advaners&type=user&single=2','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-hide" id="nexterDiv">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label"><text>*</text>指定下一步审核人</label>
                        <div class="layui-input-block relative">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=nexter&type=user&single=1','770px','490px');"></div>
                                <div class="tanxiannei" id="nexter"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=nexter&type=user&single=1','770px','490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                        </div>
                    </div>
                </div>
            </div>
            <?php include '../public/upinfo.php'?>
        </div>


    </div>
</form>
<script>
    var param_id = getQueryVariable('id') || 0;
    var param_isturn = getQueryVariable('isturn') || 0;
    if(param_isturn > 0){
        $("#billzhan").remove();
        $("#billtutn").remove();
        $("#billsub").attr('isshen', 1);
    }
    var param_billyushen = getQueryVariable('billyushen') || 0;
    if(param_billyushen == 2){
        $("#billyushen").addClass('layui-hide');
    }


    $("#commentForm").validate({
        rules: {
            name: {required: true},
        },
        messages:{
            name: {required: "请输入"},
        }
    });

    var Arr_type, Arr_nature, Arr_taxtype, Arr_piaotype, Arr_danlevel;
    function set_type(value){
        xmselect_dan('type', Arr_type, value, function (res) {
            if(res.arr && res.arr.length > 0){
                $("#type").find('xm-select').removeClass('error');
            }else{
                $("#type").find('xm-select').addClass('error');
            }
        });
    }
    function set_nature(value){
        xmselect_dan('nature', Arr_nature, value, function (res) {
            if(res.arr && res.arr.length > 0){
                $("#nature").find('xm-select').removeClass('error');
            }else{
                $("#nature").find('xm-select').addClass('error');
            }
        });
    }
    function set_taxtype(value){
        xmselect_dan('taxtype', Arr_taxtype, value);
    }
    function set_piaotype(value){
        xmselect_dan('piaotype', Arr_piaotype, value);
    }
    function set_danlevel(value){
        xmselect_dan('danlevel', Arr_danlevel, value);
    }

    layui.use(['laytp', 'form'], function() {
        var form = layui.form, layer = layui.layer;
        render_input_attr();



        facade.ajax({type: 'get', url: ask_flowdata_edit_dealcom_geng, data:{id:param_id}}).done(function(res){
            if (res.code === 2000) {
                var data = res.data.data;
                $("#flowsetname").text(data.flowsetname);
                $("#flowuser").val(data.flowuser);
                $("#flowdept").val(data.flowdept);
                if(data.isadvan){
                    $("#advanersDiv").removeClass('layui-hide');
                    if(data.advaners_info.length > 0){
                        tan_tags_init('#advaners', data.advaners_info);
                    }
                }
                if(data.isnext){
                    $("#nexterDiv").removeClass('layui-hide');
                    if(data.nexter_info.length > 0){
                        tan_tags_init('#nexter', data.nexter_info);
                    }
                }
                if(data.flowrelas_info.length > 0){
                    set_choose_btn_more('flowrelas',data.flowrelas_info);
                }


                $("#name").val(data.name);
                $("#legaler").val(data.legaler);
                $("#zhuaddr").val(data.zhuaddr);
                $("#taxtype").val(data.taxtype);
                $("#piaotype").val(data.piaotype);
                $("#rate").val(data.rate);
                $("#ratenum").val(data.ratenum);
                $("#unitaddr").val(data.unitaddr);
                $("#phone").val(data.phone);
                $("#bankname").val(data.bankname);
                $("#banknum").val(data.banknum);
                $("#genre").val(data.genre);
                $("#lianer").val(data.lianer);
                $("#liantel").val(data.liantel);
                $("#explain").val(data.explain);


                var dealid_info = res.data.dealid_info;
                if(dealid_info){
                    set_choose_btn('dealid',dealid_info.id,dealid_info.name);
                }

                Arr_type = res.data.type;
                Arr_nature = res.data.nature;
                Arr_taxtype = res.data.taxtype;
                Arr_piaotype = res.data.piaotype;
                Arr_danlevel = res.data.danlevel;

                xmselect_dan('type', res.data.type, data.type, function (res) {
                    if(res.arr && res.arr.length > 0){
                        $("#type").find('xm-select').removeClass('error');
                    }else{
                        $("#type").find('xm-select').addClass('error');
                    }
                });
                xmselect_dan('nature', res.data.nature, data.nature, function (res) {
                    if(res.arr && res.arr.length > 0){
                        $("#nature").find('xm-select').removeClass('error');
                    }else{
                        $("#nature").find('xm-select').addClass('error');
                    }
                });
                xmselect_dan('taxtype', res.data.taxtype, data.taxtype);
                xmselect_dan('piaotype', res.data.piaotype, data.piaotype);
                xmselect_dan('danlevel', res.data.danlevel, data.danlevel);


                if(data.advaners_info.length > 0){
                    tan_tags_init('#advaners', data.advaners_info);
                }

                public_upload_file_load('upload_files', res.data.files);
                render_from();
            }
        });


        form.on('submit(add)', function(data){
            data.field.isturn = $(this).attr('key') || 0;
            data.field.isshen = $(this).attr('isshen') || 0;
            data.field.flowrelas = get_choose_val('flowrelas');
            data.field.advaners = tan_tags_getvalue("#advaners", 'user');
            data.field.nexter = tan_tags_getvalue("#nexter", 'user');

            data.field.dealid = get_choose_val('dealid');
            if(data.field.isturn > 0){
                var validRes = $("#commentForm").valid();

                formValid('dealid');
                if(data.field.dealid == undefined || !data.field.dealid){
                    validRes = false;
                }

                if(!data.field.type){
                    $("#type").find('xm-select').addClass('error');
                    validRes = false;
                }else{
                    $("#type").find('xm-select').removeClass('error');
                }
                if(!data.field.nature){
                    $("#nature").find('xm-select').addClass('error');
                    validRes = false;
                }else{
                    $("#nature").find('xm-select').removeClass('error');
                }

                if(!validRes){return false;}
            }

            data.field.advaners = tan_tags_getvalue("#advaners", 'user');

            data.field.id = param_id;
            data.field.files = public_upload_file_value('upload_files');

            public_flow_submit(data.field, ask_flowdata_add_dealcom_geng, ask_flowdata_edit_dealcom_geng, $(this).attr('but'));
            return false;
        });

    });




</script>
</body>
</html>
